package com.hanshunping.oop.constuctor;

public class Construtor01 {
    public static void main(String[] args) {
        System.out.println("============");
        Person p1 = new Person();//无参构造器
        System.out.println(p1.age + " " + p1.name);
        System.out.println("================================");
        Person p2 =new Person("狗屎",50);//有参的构造器
        System.out.println(p2.age + " " + p2.name);
    }
}
class Person{
    //成员变量
    String name;
    int age;
    //无参的构造器
    public Person(){
        age = 18;
    }
    //有参数的构造器
    public Person(String pName, int pAge) {
        name = pName;
        age = pAge;
    }
}

